{% extends "ponsol2web/base_generic.html" %}
{% block title %}
    Result
{% endblock %}

{% block content_title %} Pon-Sol2 Result{% endblock %}
{% block content_title_describe %}
    The results are listed according to your IP.
{% endblock %}
{% block content %}
    <div class="page-header">
        <h1>Predict Results<small></small></h1>
    </div>
    {% if count > 0 %}
        <div id="result_list row">
            <table class="table table-hover" >
                <tr class="">
                    <th class="col-md-1">#</th>
                    <th class="col-md-1">Status</th>
                    <th class="col-md-1">Input Type</th>
                    <th class="col-md-2">Start Time</th>
                    <th class="col-md-2">End Time</th>
                    <th class="col-md-4">Message</th>
                    {% for task in page_obj %}
                        <tr>
                            <td class="text-capitalize">{{ forloop.counter }}</td>
                            <td class="text-capitalize"><a
                                    href="{% url "ponsol2:task-detail" task.id %}">{{ task.status }}</a></td>
                            <td>{{ task.get_input_type_display }}</td>
                            <td>{{ task.start_time }}</td>
                            <td>{{ task.finish_time }}</td>
                            <td>
                                {% if task.error_msg %}
                                    <span class="alert-danger">
                                    {{ task.error_msg }}
                                    </span>
                                {% else %}
                                    Run correctly.
                                {% endif %}
                            </td>
                        </tr>
                    {% endfor %}
            </table>
            {% if count > 1 %}
                <div>
                    <nav aria-label="Page navigation">
                        <ul class="pagination">
                            <li>
                                <a href="?page=1" aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </li>
                            <li>
                                <a href="?page={{ page_obj.number|add:-1 }}" aria-label="Previous">
                                    <span aria-hidden="true">&lsaquo;</span>
                                </a>
                            </li>

                            {% for index, href in page_list %}
                                {% if index == page_obj.number %}
                                    <li class="active"><a href="{{ href }}">{{ index }}</a></li>
                                {% else %}
                                    <li><a href="{{ href }}">{{ index }}</a></li>
                                {% endif %}
                            {% endfor %}


                            <li>
                                <a href="?page={{ page_obj.number|add:1 }}" aria-label="Next">
                                    <span aria-hidden="true">&rsaquo;</span>
                                </a>
                            </li>
                            <li>
                                <a href="?page={{ count }}" aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </li>
                        </ul>
                    </nav>
                </div>

            {% endif %}

        </div>
    {% else %}
        <p> You have not commit any task.</p>
    {% endif %}

{% endblock %}
